use std::mem::MaybeUninit;

use jni::JavaVM;
use tokio::runtime::{Builder, Runtime};


static mut JAVA_VM: MaybeUninit<JavaVM> = MaybeUninit::uninit();
static mut RT: MaybeUninit<Runtime> = MaybeUninit::uninit();


pub fn init(vm: JavaVM) {
    let rt = Builder::new_multi_thread()
        .worker_threads(2)
        .enable_all()
        .build().unwrap();
    unsafe {
        JAVA_VM.write(vm);
        RT.write(rt);
    }
}

pub fn get_java_vm() -> &'static JavaVM {
    unsafe { JAVA_VM.assume_init_ref() }
}

pub fn get_rt() -> &'static Runtime {
    unsafe { RT.assume_init_ref() }
}







